diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-05-03 10:38:52 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-05-03 10:38:52 +0700 |
| commit | b4abdb00ef83aa824e8a05d5b75df48adb7b9629 (patch) | |
| tree | 86ce2454793fe31b54a87f151433cbf86dbed134 /src/pages/shop/product/[slug].jsx | |
| parent | 31816dc3a6cb62e1480524c8f0065a7835fefdcd (diff) | |
semi dynamic page
Diffstat (limited to 'src/pages/shop/product/[slug].jsx')
| -rw-r--r-- | src/pages/shop/product/[slug].jsx | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/pages/shop/product/[slug].jsx b/src/pages/shop/product/[slug].jsx index 7ab0ef76..ed6c27d5 100644 --- a/src/pages/shop/product/[slug].jsx +++ b/src/pages/shop/product/[slug].jsx @@ -4,24 +4,22 @@ import { getIdFromSlug } from '@/core/utils/slug' import productApi from '@/lib/product/api/productApi' import dynamic from 'next/dynamic' import { useRouter } from 'next/router' -import { useEffect, useState } from 'react' const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout')) const Product = dynamic(() => import('@/lib/product/components/Product/Product')) export async function getServerSideProps(context) { const { slug } = context.query - + let product = await productApi({ id: getIdFromSlug(slug) }) if (product?.length == 1) { product = product[0] const regexHtmlTags = /(<([^>]+)>)/gi const regexHtmlTagsExceptP = /<\/?(?!p\b)[^>]*>/g - if (product.description.replace(regexHtmlTags, ' ').trim() == '') { - product.description = '' - } - product.description = product.description.replace(regexHtmlTagsExceptP, ' ') - product.description = product.description.trim() + product.description = product.description + .replace(regexHtmlTagsExceptP, ' ') + .replace(regexHtmlTags, ' ') + .trim() } else { product = null } |
